import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './plugins/element.js'
import './assets/css/global.css'
import './assets/fonts/iconfont.css'/* 引入第三方图标库 */
import axios from 'axios'
import treeTable from 'vue-table-with-tree-grid'
import editor from 'vue-quill-editor'/* 导入富文本编辑器 */
import 'quill/dist/quill.core.css' // import styles默认样式
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme

axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'; // 导入全局的基本接口
axios.interceptors.request.use(config => { // 令牌申请权限
  config.headers.Authorization = window.sessionStorage.getItem('token');
  return config;
})
Vue.prototype.$http = axios;
Vue.config.productionTip = false
Vue.filter('dateFormat', function (originVal) { // 时间格式过滤器
  const dt = new Date(originVal);
  const year = dt.getFullYear();
  const month = (dt.getMonth() + 1 + '').padStart(2, '0');
  const days = (dt.getDate() + '').padStart(2, '0');
  const hour = (dt.getHours() + '').padStart(2, '0');
  const min = (dt.getMinutes() + '').padStart(2, '0');
  const sec = (dt.getSeconds() + '').padStart(2, '0');
  return `${year}-${month}-${days} ${hour}:${min}:${sec}`;
})
Vue.component('tree-table', treeTable)
Vue.use(editor)/* 注册富文本编辑器为全局可用 */
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
